package com.gistmap.sideline.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectRabbitConfig {

    /**
     * 队列
     * @return
     */
    @Bean
    public Queue mailDirectQueue() {
        return new Queue("mailDirectQueue", true);
    }

    /**
     * 交换机
     * @return
     */
    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("directExchange");
    }

    /**
     * 队列与交换机绑定
     * @return
     */
    @Bean
    public Binding bindingDirect(){
        return BindingBuilder
                .bind(mailDirectQueue())
                .to(directExchange())
                .with("mailRouting");
    }
}
